load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "contentionpb",
    srcs = ["contention.go"],
    embed = [":contentionpb_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/contentionpb",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/sql/clusterunique",
        "//pkg/util",
        "//pkg/util/encoding",
        "//pkg/util/uuid",
    ],
)

proto_library(
    name = "contentionpb_proto",
    srcs = ["contention.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/kv/kvpb:kvpb_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
        "@com_google_protobuf//:duration_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

go_proto_library(
    name = "contentionpb_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/contentionpb",
    proto = ":contentionpb_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/kv/kvpb",
        "//pkg/roachpb",  # keep
        "//pkg/sql/appstatspb",  # keep
        "//pkg/sql/catalog/descpb",  # keep
        "//pkg/sql/clusterunique",  # keep
        "//pkg/util/uuid",  # keep
        "@com_github_gogo_protobuf//gogoproto",
    ],
)

go_test(
    name = "contentionpb_test",
    srcs = ["contention_test.go"],
    embed = [":contentionpb"],
    deps = [
        "//pkg/sql/clusterunique",
        "//pkg/util",
        "//pkg/util/uint128",
        "//pkg/util/uuid",
        "@com_github_stretchr_testify//require",
    ],
)
